package com.esri.android.map;

import android.util.Log;
import com.esri.android.map.event.MapLoadAction;
import com.esri.android.map.event.OnWebMapLoadListener;
import com.esri.core.internal.tasks.d;
import com.esri.core.io.UserCredentials;
import com.esri.core.portal.WebMap;
import com.esri.core.portal.WebMapLayer;
import java.io.InterruptedIOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

/* loaded from: classes.dex */
class a<V> implements Callable<C0012a<V>> {
    final d<V> a;
    final OnWebMapLoadListener b;
    final WebMap c;
    final MapView d;
    final WebMapLayer e;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.esri.android.map.a$a  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static class C0012a<V> {
        V a;
        UserCredentials b;

        C0012a(V v, UserCredentials userCredentials) {
            this.a = v;
            this.b = userCredentials;
        }
    }

    public a(d<V> dVar, WebMap webMap, MapView mapView, WebMapLayer webMapLayer, OnWebMapLoadListener onWebMapLoadListener) {
        this.a = dVar;
        this.b = onWebMapLoadListener;
        this.c = webMap;
        this.d = mapView;
        this.e = webMapLayer;
    }

    C0012a<V> a(Exception exc) {
        MapLoadAction<UserCredentials> onWebMapLoadError = this.b.onWebMapLoadError(this.d, this.c, this.e, null, exc, this.a.getCredentials());
        if (onWebMapLoadError != null && onWebMapLoadError.getAction() != null) {
            int i = AnonymousClass1.a[onWebMapLoadError.getAction().ordinal()];
            if (i == 1) {
                Log.i(com.esri.core.internal.a.a, "WebMap Action: CONTINUE_OPEN_AND_SKIP_CURRENT_LAYER");
                return null;
            } else if (i == 2) {
                Log.i(com.esri.core.internal.a.a, "WebMap Action: CONTINUE_OPEN_WITH_THE_PARAMETER");
                this.a.setCredentials(onWebMapLoadError.getParameter());
                return call();
            } else {
                Log.i(com.esri.core.internal.a.a, "WebMap Action: CANCEL_OPEN");
            }
        }
        if (this.c == null) {
            this.d.a(exc);
        }
        return null;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: com.esri.android.map.a$1  reason: invalid class name */
    /* loaded from: classes.dex */
    public static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[MapLoadAction.Action.values().length];
            a = iArr;
            try {
                iArr[MapLoadAction.Action.CONTINUE_OPEN_AND_SKIP_CURRENT_LAYER.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[MapLoadAction.Action.CONTINUE_OPEN_WITH_THE_PARAMETER.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[MapLoadAction.Action.CANCEL_OPEN.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    @Override // java.util.concurrent.Callable
    /* renamed from: a */
    public C0012a<V> call() {
        try {
            return new C0012a<>(this.a.execute(), this.a.getCredentials());
        } catch (InterruptedIOException | InterruptedException | ExecutionException unused) {
            return null;
        } catch (Exception e) {
            if (!Thread.currentThread().isInterrupted()) {
                if (this.b != null) {
                    return a(e);
                }
                if (this.c == null) {
                    this.d.a(e);
                }
            }
            return null;
        }
    }
}
